<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 								
	<head> 							
		<%@ include file="../jslib/jquerylib.jsp" %>
	    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
	     <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
        <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=request.getContextPath() %>/jslib/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
        <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/ztree/jquery.ztree.core-3.4.js"></script>
	       <!-- 删除结果信息返回 -->
	    	<c:if test="${requestScope.message!=null}">
				<script type="text/javascript">
	  	 		     alert('<c:out value="${requestScope.message}"></c:out>');
	  	 		     window.close();
	  			</script>
	        </c:if>
	 
	<script type="text/javascript">
	$(document).ready(function(){
					$("#gridTable").jqGrid({
						url:'<%=request.getContextPath() %>/oru!queryOrDataList.action',
						datatype: "json",
						height: 500,
						width: 710, 
						autowidth: true, 
						colNames:['序号','原始记录编号','原始记录URL','所属流程名称','委托单号','委托单位','创建人','创建时间','原始记录名称'],
						colModel:[
								{name:'orId',index:'orId', width:100, key:true,hidden:true,hidedlg:true}, 
								{name:'orCode',index:'orCode', width:150},
								{name:'orUrl',index:'orUrl', width:100,hidden:true},	
								{name:'orLcName',index:'orLcName', width:150},	
								{name:'orWtdh',index:'orWtdh', width:150},	
								{name:'orWtdw',index:'orWtdw', width:100},	
								{name:'orCreater',index:'orCreater', width:100},
								{name:'orCreateTime',index:'orCreateTime', width:100},
								{name:'orName',index:'orName', width:120}						
							
		
					],
					shrinkToFit:false,
					sortname:'orCode',
					sortorder:'desc',
					viewrecords:true,
					multiselect: true, // 是否显示复选框
					multiboxonly : true, 
					//gridview: true,  //提升速度
					rownumbers: true,//显示行号
					rownumWidth: 30, //行号的宽度
					rowNum:15,
					rowList:[15,20,50,400,510],
					toolbar: [false,"top"],
					loadComplete: function() {
						var ids = jQuery("#gridTable").getDataIDs();
				        if(ids.length<20){
				        	 jQuery("#gridTable").jqGrid('setGridHeight',390); 
				        	// parent.document.getElementById("mainframe").height=670; 
				        }else{
				        	 jQuery("#gridTable").jqGrid('setGridHeight',ids.length*24); 
				        	 parent.document.getElementById("mainframe").height=ids.length*24+410; 
				        }
				        //var n = jQuery("#gridTable").getGridParam('records'); 
         		        for(i=0;i<ids.length;i++){
         		        	var data =jQuery("#gridTable").getRowData(ids[i]); 
         		        	if(data.epMinstock>=data.epActualstock){
								$("#"+ids[i]).find(".biaohong").css("background-color", "red"); 
							}
         		        }
					},
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
					pager:"#gridPager",
					caption: "原始记录列表"
			});
			    $("#consoleDlg").dialog({
			        autoOpen: false,      
			        modal: true,    // 设置对话框为模态（modal）对话框  
			        resizable: true,      
			        width: 700,  
			        buttons: {  // 为对话框添加按钮  
			            "关闭": function() {$("#consoleDlg").dialog("close")}
			        }  
			    }); 
				 jQuery("#gridTable").jqGrid('navGrid','#gridPager',{add:false,edit:false,del:false,search:false,refresh:false});
					jQuery("#gridTable").jqGrid('navButtonAdd','#gridPager',
								{ 	
								caption: "",                          
								onClickButton : function (){                               
								jQuery("#gridTable").jqGrid('setColumns');                           
								}
					}); 
								doResize(); 
							//	afterCompleteFunction();										
	}); 
	
	//执行大小
	function doResize() { 
		var ss = getPageSize(); 
		//alert(ss.WinH);
		
			 $("#gridTable").jqGrid('setGridHeight', ss.WinH-245);
			 $("#gridTable").jqGrid('setGridWidth', ss.WinW-30); 
			} 
		//查询
		function gridSearch(){
			var lcName = $.trim(jQuery("#lcName").val());
            var orCode = $.trim(jQuery("#orCode").val());      
            var params = {  
                        "orCode" : encodeURIComponent(orCode),                           
                        "lcName" : encodeURIComponent(lcName),                                 
                        }
            var postData = $("#gridTable").jqGrid("getGridParam", "postData");
            $.extend(postData, params);
			jQuery("#gridTable").jqGrid('setGridParam',
			{
				url:'<%=request.getContextPath() %>/oru!queryOrDataList.action'
			}).trigger("reloadGrid", [{page:1}]);
        } 
       
		//刷新
		function refreshIt(){
			reset();
			gridSearch();
		}
		//清空
		function reset(){
			jQuery("#lcName").val("");
			jQuery("#orCode").val("");
		}
		
		function Recorder(){
			
		}
		//查看
		function chakan(){
			var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
			if (!ids) {
			    alert("请先选择记录!");  
			    return false;  
			}
			if(ids.indexOf(",")!=-1){
				  alert("只能选择一条记录!");  
			        return false; 
			}
			var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
			var id = String(row.id);//获取选中行的id属性.
			var oruUrl=String(row.orUrl);
			$.dialog({
		        title: '原始记录数据信息查看',
		        content: 'url:<%=request.getContextPath() %>/oru!queryOrUrl.action?oruUrl='+oruUrl,
		        okVal: false,//确定按钮文字
		        cancelVal: false,//取消按钮文字
		        min: true, //是否显示最小化按钮
		        max: false,//是否显示最大化按钮
		        fixed: false,//开启静止定位
		        lock: true,//开启锁屏
		        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
		        time: null,//设置对话框显示时间
		        resize: true,//是否允许用户调节尺寸
		        drag: true,//是否允许用户拖动位置
		        cache: false,//是否缓存iframe方式加载的窗口内容页
		        width: '900px',
		        height: 680
			});
			
			
		}
		
		//发起原始记录修改流程
		function ruku(){
			var epids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
			if (!epids) {
			    alert("请先选择记录!");  
			    return false;  
			}
			if(epids.indexOf(",")!=-1){
				  alert("只能选择一条记录!");  
			        return false; 
			}
			var row = jQuery("#gridTable").jqGrid('getRowData',epids);//获取选中行.
			var orid = row.ID;//获取选中行的id属性.
			$.dialog({
		        title: '发起原始记录修改流程',
		        content: 'url:<%=request.getContextPath() %>/oru!oruFlowFaQi.action?flowid=2401&stateid=orufaqi&orId='+epids,
		        okVal: false,//确定按钮文字
		        cancelVal: false,//取消按钮文字
		        min: true, //是否显示最小化按钮
		        max: false,//是否显示最大化按钮
		        fixed: false,//开启静止定位
		        lock: true,//开启锁屏
		        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
		        time: null,//设置对话框显示时间
		        resize: true,//是否允许用户调节尺寸
		        drag: true,//是否允许用户拖动位置
		        cache: false,//是否缓存iframe方式加载的窗口内容页
		        scrollbar:"yes",
		        width: '930px',
		        height: 600
			});
		}
		function chuku(){}
		
	      
	</script>	
	</head>
	<body>
	<form action="" method="post" id="form1">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
		   		<td>
			 		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="font12Black_B">
			   		<tr>
			        	<td width="8%" height="35" align="right">试验流程名称：</td>
			        	<td width="12%"><input type="text" name="lcName" id="lcName" class="search_InputText" style="width:99%;"/></td>
			        	
			       		<td width="8%" height="35" align="right">原始记录编号：</td>
			       	    <td width="12%"><input type="text" name="orCode" id="orCode"  class="search_InputText" style="width:99%;" /></td>
			       	 	<td width="15%" align="center"><input type="button" name="button" id="button" value="查询" onclick="gridSearch()" class="search_Btn" />
			      			&nbsp;<input type="reset" name="button2" id="button2" value="清空" onclick="reset()" class="search_Btn" />
			      		</td>
			      	</tr>
			      </table>
			    
		  		</td>
		 	  </tr>
		      <tr>
                <td align="right" height="9" class="sclinebotBg"></td>
	          </tr>
		      <tr>
			    <td width="92%" align="right"><div class="btnStatus" id="flip"></div></td>
			    <td width="8%">&nbsp;</td>
			  </tr>
			</table>
			<table style="width: 100%;" class="tableCont">
			  	<tr>
					<td height="25" valign="top">
					<input id="search" type='button' value='查看' onclick='chakan()' class='button_b' />
					<input id="update1" type='button' value='发起原始记录修改流程' onclick='ruku()' class='button_b' />		
				    
				
				</td>
				</tr>
				<tr>
					<td colspan="4" style="padding-top:8px;">
						<table id="gridTable"></table>
						<div id="gridPager"></div>
					</td>
				</tr>
		   </table>
	</form>
	</body>
</html>
